#!/usr/bin/env node
/*
 * @Author: momokara
 * @description: 插件入口文件
 */

const path = require("path");
// 调用的方法
const {
  cgetpages: getpages,
  cgetFileMap: getFileMap,
  cgetYapi: getYapi,
} = require("./bin/main");
const { showMenu } = require("./bin/meunCtrl");
let rootPath = process.cwd();
rootPath = path.resolve(rootPath, "src");

const menus = [
  {
    name: "todo",
    message: "你要干啥",
    type: "rawlist", // 有序列表有个数
    choices: [
      { name: "获取pages", value: "getPages" },
      { name: "获取fileMap", value: "getFileMap" },
      { name: "同步yapi", value: "getyapiData" },
      { name: "没事", value: "nothing" },
    ],
    default: 0,
  },
];

showMenu(menus).then((res) => {
  switch (res.todo) {
    case "getPages":
      getpages(rootPath);
      break;
    case "getFileMap":
      getFileMap(rootPath);
      break;
    case "getyapiData":
      getYapi(rootPath);
      break;

    default:
      break;
  }
});

module.exports = require("./bin/main");
